<?php

(!defined('IN_DISCUZ') || !IN_ADMIN) && exit('Access Denied');
require_once DISCUZ_ROOT.'./config/config_ucenter.php';
$sql = <<< SQL
DROP TABLE IF EXISTS `pre_renren_connect`;
CREATE TABLE IF NOT EXISTS `pre_renren_connect` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `dz_uid` int(10) unsigned NOT NULL,
  `rr_uid` int(10) unsigned NOT NULL,
  `tag` int(2) unsigned NOT NULL,
  `bind_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `dz_uid` (`dz_uid`),
  KEY `rr_uid` (`rr_uid`,`tag`)
) ENGINE=MyISAM;
SQL;

if(submitcheck('installsubmit', 1)){
	if(submitcheck('installsj', 1)) 
	{
		$sql1=DB::query("Describe ".DB::table('common_member_profile')." renren");
		$test = mysql_fetch_array($sql1);
		if(!$test){
			runquery($sql);
			DB::query("alter table ".DB::table('common_member_profile')." add `renren` varchar(255)");
		}
		else{runquery($sql);}

		DB::query("INSERT INTO ".DB::table('common_member_profile_setting')." VALUES 	('renren','1','1','0','人人网主页','','0','0','0','0','0','0','0','text','0','','') ON DUPLICATE KEY UPDATE `fieldid` = 'renren'");
		DB::query("alter table ".DB::table('common_member')." MODIFY `username` varchar(30) DEFAULT '0'");
		DB::query("alter table ".UC_DBTABLEPRE."members MODIFY `username` varchar(30) DEFAULT '0'", "quiet");
	}
	$finish = true;
}else{
	$html ="<form action=\"$BASESCRIPT?action=plugins&operation=$operation&dir=$dir&installtype=$installtype&instype=$instype&formhash=$formhash&installsubmit=yes&installsj=yes\" method=\"post\">".
		'<input type="submit" class="btn" value="全新确认安装数据库" /></form>'.
		"<form action=\"$BASESCRIPT?action=plugins&operation=$operation&dir=$dir&installtype=$installtype&instype=$instype&formhash=$formhash&installsubmit=yes\" method=\"post\">".
		'<input type="submit" class="btn" value="保留数据库安装" /></form>';

	cpmsg($html);
}

?>
